package com.sh.data.engine.domain.normalization.modeldesign.busmatrix.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.sh.data.engine.domain.normalization.modeldesign.busmatrix.model.domain.BusMatrixDomain;
import com.sh.data.engine.domain.normalization.modeldesign.busmatrix.model.domain.LogicRelFieldDomain;
import com.sh.data.engine.domain.normalization.modeldesign.busmatrix.model.param.SaveBizRelParam;
import com.sh.data.engine.domain.normalization.modeldesign.busmatrix.model.param.SaveLogicRelParam;
import com.sh.data.engine.domain.normalization.modeldesign.model.model.domain.ModelDomain;
import com.sh.data.engine.domain.normalization.modeldesign.model.model.domain.ModelIdNameDomain;
import com.sh.data.engine.domain.normalization.research.themedesign.model.domain.ThemeDomain;
import com.sh.data.engine.repository.dao.normalization.modeldesign.busmatrix.entity.MatrixEntity;
import com.sh.data.engine.repository.dao.normalization.modeldesign.dimfact.entity.DimFactEntity;
import org.springframework.data.util.Pair;

import java.util.List;

/**
 * @author : changkong
 * @date : 2022/1/10
 */
public interface BusMatrixService extends IService<MatrixEntity> {

    List<ThemeDomain> getThemesByProjectId(Long projectId, String modelType);

    BusMatrixDomain rebuildMatrix(
        List<MatrixEntity> sourceMatrix,
        List<DimFactEntity> rowSortedList,
        List<DimFactEntity> colSortedList,
        DimFactEntity insertEntity);

    BusMatrixDomain getBusMatrixByTheme(Long themeId);

    List<MatrixEntity> getBusMatrixEntityByFactIdsAndDimIds(List<Long> factId, List<Long> dimId);

    void saveBizRelRequest(SaveBizRelParam copyProperties);

    BusMatrixDomain buildApiMatrix(
        List<DimFactEntity> factRows, List<DimFactEntity> dimCols, List<MatrixEntity> sourceMatrix);

    Boolean isRowColBindField(String type, Long id);

    List<ModelIdNameDomain> getModelListByType(Long themeId, String type);

    List<LogicRelFieldDomain> getLogicRelFieldList(Long factRowId, Long dimColId);

    void saveLogicRel(SaveLogicRelParam saveLogicRelParam);

    Pair<List<ModelDomain.Field>, List<ModelDomain.Field>> getDimFieldFactFieldList(
        Long projectId, Long factId, Long dimId);

    void deleteMatrixItems(Long id, String type);

    List<MatrixEntity> getMatrixByFactId(Long factId);
}
